package com.csdj.essay.service;

import com.csdj.essay.entity.Article;
import com.csdj.essay.entity.TQuestion;
import com.csdj.essay.mapper.TQuestionMapper;
import com.csdj.essay.service.ITQuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 问题表 服务实现类
 * </p>
 *
 * @author 刘宇
 * @since 2022-03-17
 */
@Service
public class TQuestionService extends ServiceImpl<TQuestionMapper, TQuestion> implements ITQuestionService {

    @Resource
    private TQuestionMapper tQuestionMapper;


    /**
     * 查询全部，推荐模块
     * @return
     */
    @Override
    public List<TQuestion> getInfo(){
        List <TQuestion>list = tQuestionMapper.getInfo();
        return list;
    }

    /**
     * 查询关注的人发布的问题
     * @return
     */
    @Override
    public List<Article> getInfoFollow(int uid) {
        List<Article> list = tQuestionMapper.getInfoFollow(uid);
        return list;
    }

    /**
     * 连表查询，主页热榜，根据访问人数进行倒序
     * @return
     */
    @Override
    public List<Map<String, Object>> getInfoHotList() {
        List<Map<String,Object>> list = tQuestionMapper.getInfoHotList();
        return list;
    }
}
